package com.yyk.yiliao.util;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * Created by Administrator on 2018/9/3 0003.
 * <p>
 * 保留两位小数点  价格  money
 */

public class CheckDecimalPointUtil {
//    public static String checkPoint(String num) {
//
//
////        StringBuilder myNum = new StringBuilder();
////        try {
////            String integerNum = num.substring(0, num.indexOf("."));
////            String decimals = num.substring(num.indexOf("."), num.length());
////            float decimalsNum = Float.valueOf(decimals);
////            if (decimalsNum > 0) {
////                myNum = myNum.append(integerNum).append(decimals);
////            } else {
////                myNum = myNum.append(integerNum);
////            }
////        } catch (NumberFormatException e) {
////            e.printStackTrace();
////        }
////        return String.valueOf(myNum);
//    }

    public static String checkPoint(float countPrice) {
        // 想要转换成指定国家的货币格式
        NumberFormat format = NumberFormat.getNumberInstance();
        format.setMaximumFractionDigits(2);
        // 把转换后的货币String类型返回
        String numString = format.format(countPrice);
        return numString;
    }

}
